<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>{$site_name}</title>
<!-- CSS -->
<link rel="stylesheet" href="{url:#css/materialize.min.css}" />
<link rel="stylesheet" href="{url:#css/me.css}" />
<link rel="stylesheet" href="{url:#css/iconfont.css}" />

<style type="text/css">
/**去除绿色下划线 - 开始*/
input::-webkit-input-placeholder {
    color: #7e7e7e;
    text-indent: 5px;
}
input:not([type]),input[type=text],input[type=password],input[type=email],input[type=url],input[type=time],input[type=date],input[type=datetime-local],input[type=tel],input[type=number],input[type=search],textarea.materialize-textarea{background-color:transparent;border:none;border-radius:0;outline:none;height:1.5em;width:100%;font-size:1rem;margin:0;padding:0;box-shadow:none;}
input:not([type]):focus:not([readonly]),input[type=text]:focus:not([readonly]),input[type=password]:focus:not([readonly]),input[type=email]:focus:not([readonly]),input[type=url]:focus:not([readonly]),input[type=time]:focus:not([readonly]),input[type=date]:focus:not([readonly]),input[type=datetime-local]:focus:not([readonly]),input[type=tel]:focus:not([readonly]),input[type=number]:focus:not([readonly]),input[type=search]:focus:not([readonly]),textarea.materialize-textarea:focus:not([readonly]){border-bottom:none;box-shadow:none}
/**去除绿色下划线 - 结束*/
</style>
<!-- JS -->
<script src="{url:#js/jquery-1.11.3.min.js}"></script>
<script src="{url:#js/materialize.min.js}"></script>
<script src="{url:#js/home/register.js}"></script>
</head>
<body>
<!-- TitleBar 开始 -->
<div class="navbar-fixed">
  <nav>
    <div class="nav-wrapper red accent-4 valign-wrapper">
      <ul class="left" id="nav-btn-left">
        <li>
        	<!-- 
        	<a><i class="iconfont">&#xe63c;</i></a>
        	-->
        </li>
      </ul>
      <center>
      <span class="title-bar-size center_align">用户注册</span>
      </center>
      <ul class="right">
        <li>
        	<!-- 
        	<a  class="disabled" style="visibility:hidden"><i class="iconfont">&#xe63c;</i></a>
        	-->
        </li>
      </ul>
    </div>
  </nav>
</div>

<!-- TitleBar 结束 -->

<div class="container">
	<div class="reg-box">
	<table>
		<tr>
			<td class="ltitle">选&nbsp;&nbsp;&nbsp;择</td>
			<td>
				{set:$tjr_jdr_user_list = Common::getTjrJdrUserList()}
				<select style="display:block;" id="sel_change">
					<option value="0">--请选择--</option>
					{if:!empty($tjr_jdr_user_list)}
					{list:items=$tjr_jdr_user_list}
					<option value="{$item['name']}">{$item['name']}</option>
					{/list}
					{/if}
				</select>
			</td>
		</tr>
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		<tr>
			<td class="ltitle">介绍人</td>
			<td><input name="tjrname" id="tjrname" type="text" value="{$tjr_name|''}"  placeholder="介绍人账号"/></td>
		</tr>
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		<tr>
			<td class="ltitle">接收人</td>
			<td><input name="jdrname" id="jdrname" type="text" placeholder="接收人账号"/></td>
		</tr>
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		<tr>
			<td class="ltitle">注册人</td>
			<td><input name="username" id="username" type="text" placeholder="注册人账号"/></td>
		</tr>
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		<!-- 
		<tr>
			<td class="ltitle">手机号</td>
			<td><input name="mobile" id="mobile" type="text" placeholder="请输入手机号"/></td>
		</tr>
		
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		-->
		<tr>
			<td class="ltitle">密&nbsp;&nbsp;&nbsp;码</td>
			<td><input id="password" name="password" type="password" placeholder="请输入密码"/></td>
		</tr>
		<tr><td colspan="2"><div class="divider"></div></td></tr>
		<tr>
			<td class="ltitle">确&nbsp;&nbsp;&nbsp;认</td>
			<td><input name="repassword" id="repassword" type="password" placeholder="请确认密码"/></td>
		</tr>
	</table>
	</div>
	<div class="center clearfix" style="margin-right:10px; margin-left:10px;margin-top:20px;">
		<a class="waves-effect waves-light btn-large red z-depth-0 login_btn" id="btn_reg" onclick="sub_reg()">注&nbsp;&nbsp;册</a>
	</div>
</div>

<script type="text/javascript">
$(function(){
	$("#sel_change").change(function(){
		var sel_change_val = $("#sel_change").val();
		if(sel_change_val == 0)
		{
			$("#tjrname").val("");
			$("#jdrname").val("");
		}
		else
		{
			$("#tjrname").val( sel_change_val );
			$("#jdrname").val( sel_change_val );
		}
	});


	
	$("#btn_reg").click(function(){
	
		var tjrname  = $("#tjrname").val();
		var jdrname  = $("#jdrname").val();
		var username  = $("#username").val();
		//var mobile   = $("#mobile").val();
		var password = $("#password").val();
		var repassword = $("#repassword").val();
		
		var user_pattern = /[a-zA-Z0-9]{6,}/i;
		var password_pattern = /[a-zA-Z0-9]{6,20}/i;
		var mobile_pattern = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
		
		if( tjrname == '' )
		{
			alert('介绍人不能为空');
			return;
		}

		if(!user_pattern.test(tjrname))
		{
			alert('您输入的介绍人账号不合法(至少6位字母、数字组合)');
			return;
		}
		
		if( jdrname == '' )
		{
			alert('接受人不能为空');
			return;
		}

		if(!user_pattern.test(jdrname))
		{
			alert('您输入的接收人账号不合法(至少6位字母、数字组合)');
			return;
		}

		if( username == '' )
		{
			alert('注册人不能为空');
			return;
		}

		if(!user_pattern.test(username))
		{
			alert('您输入的注册人账号不合法(至少6位字母、数字组合)');
			return;
		}

		

		if( password == '' )
		{
			alert('密码不能为空');
			return;
		}

		if( !password_pattern.test( password ) )
		{
			alert('您输入的密码不合法');
			return;
		}
		
		
		if(repassword == '')
		{
			alert('确认密码不能为空');
			return;
		}

		if( !password_pattern.test( repassword ) )
		{
			alert('您输入的确认密码不合法');
			return;
		}

		if( password != repassword)
		{
			alert('两次输入的密码不一致');
			return;
		}
		$("#btn_reg").unbind('click');
		$.post('{url:/wymobile/reg_act}',{tjrname:tjrname,jdrname:jdrname,username:username,password:password,repassword:repassword},function(data){
	        if(data['status']=='success')
		    {
			    alert('注册成功');
			    //个人中心页面
	            document.location.href="{url:/wymobile/download}";
	        }
	        else
		    {
	            alert(data['msg']);
	            
	            document.location.href="{url:/wymobile/reg}";
	        }
	      },'json');
		
	});
	
	
});



</script>

</body>
</html>
